#include "bsp_usart.h"
#include "usart.h"
#include "adc_task.h"
#include "crc_t.h"
#include "keys_task.h"
#include "bsp_dwt.h"
uint8_t usart1_tx[39] = {0xA5,0x1E,0x00,0x08,0xBF ,0x02,0x03};

uint32_t cnt_last = 0 ;
float delta_time = 0;

void send_task(void const * argument)
{
	
	DWT_Init(168);
	
	while(1){
		
		
		delta_time = DWT_GetDeltaT(&cnt_last);
		
		usart1_tx[7] = AD_Value[0]>>8;
		usart1_tx[8] = AD_Value[0];
		

		usart1_tx[9] = AD_Value[1]>>8;
		usart1_tx[10] = AD_Value[1];
		

		usart1_tx[11] = AD_Value[2]>>8;
		usart1_tx[12] = AD_Value[2];
		

		usart1_tx[13] = AD_Value[3]>>8;
		usart1_tx[14] = AD_Value[3];
		

		usart1_tx[15] = AD_Value[4]>>8;
		usart1_tx[16] = AD_Value[4];
		

		usart1_tx[17] = AD_Value[5]>>8;
		usart1_tx[18] = AD_Value[5];
		

		usart1_tx[19] = AD_Value[6]>>8;
		usart1_tx[20] = AD_Value[6];
	
	
//		usart1_tx[21] = pump_flag[0];
//		usart1_tx[22] = pump_flag[1];
//		usart1_tx[23] = pump_flag[2];

		usart1_tx[21] = keys_value[0];
		usart1_tx[22] = keys_value[1];
		usart1_tx[23] = keys_value[2];
		usart1_tx[24] = keys_value[3];
		usart1_tx[25] = keys_value[4];
		usart1_tx[26] = keys_value[5];
		
		
		Append_CRC16_Check_Sum(usart1_tx,39);
		
		HAL_UART_Transmit(&huart1,usart1_tx,39,0xff);
		
		vTaskDelay(27);
		
	}
	
	
}	

